00001 #ifndef _NETINET_IGMP_H_ 00002 #define _NETINET_IGMP_H_ 00003 00004 /* 00005 * Copyright (C) 2007 by egnite Software GmbH. All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. Neither the name of the copyright holders nor the names of 00017 * contributors may be used to endorse or promote products derived 00018 * from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00023 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE 00024 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00025 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00027 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00028 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00029 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00030 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * For additional information see http://www.ethernut.de/ 00034 * 00035 * - 00036 * Copyright (c) 1988 Stephen Deering. 00037 * Copyright (c) 1992, 1993 00038 * The Regents of the University of California. All rights reserved. 00039 * 00040 * Redistribution and use in source and binary forms, with or without 00041 * modification, are permitted provided that the following conditions 00042 * are met: 00043 * 1. Redistributions of source code must retain the above copyright 00044 * notice, this list of conditions and the following disclaimer. 00045 * 2. Redistributions in binary form must reproduce the above copyright 00046 * notice, this list of conditions and the following disclaimer in the 00047 * documentation and/or other materials provided with the distribution. 00048 * 3. Neither the name of the University nor the names of its contributors 00049 * may be used to endorse or promote products derived from this software 00050 * without specific prior written permission. 00051 * 00052 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00053 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00054 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00055 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00056 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00057 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00058 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00059 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00060 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00061 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00062 * SUCH DAMAGE. 00063 */ 00064 00065 /* 00066 * $Log$ 00067 * Revision 1.3 2008/08/11 07:00:23 haraldkipp 00068 * BSD types replaced by stdint types (feature request #1282721). 00069 * 00070 * Revision 1.2 2007/08/29 07:43:54 haraldkipp 00071 * Documentation updated and corrected. 00072 * 00073 * Revision 1.1 2007/05/02 11:18:32 haraldkipp 00074 * IGMP support added. Incomplete. 00075 * 00076 */ 00077 00078 #include <sys/types.h> 00079 #include <dev/netbuf.h> 00080 #include <net/if_var.h> 00081 00091 00096 typedef struct __attribute__ ((packed)) igmp IGMP; 00097 typedef struct __attribute__ ((packed)) igmp_report IGMP_REPORT; 00098 00103 struct __attribute__ ((packed)) igmp 00104 { 00105 uint8_t igmp_type; 00106 uint8_t igmp_code; 00107 uint16_t igmp_cksum; 00108 uint32_t igmp_group; 00109 }; 00110 00114 struct __attribute__ ((packed)) igmpv3 { 00115 uint8_t igmp_type; 00116 uint8_t igmp_code; 00117 uint16_t igmp_cksum; 00118 uint32_t igmp_group; 00119 uint8_t igmp_misc; 00120 uint8_t igmp_qqi; 00121 uint16_t igmp_numsrc; 00122 uint32_t igmp_sources[1]; 00123 }; 00124 00128 struct __attribute__ ((packed)) igmp_grouprec { 00129 uint8_t ig_type; 00130 uint8_t ig_datalen; 00131 uint16_t ig_numsrc; 00132 uint32_t ig_group; 00133 uint32_t ig_sources[1]; 00134 }; 00135 00139 struct __attribute__ ((packed)) igmp_report { 00140 uint8_t ir_type; 00141 uint8_t ir_rsv1; 00142 uint16_t ir_cksum; 00143 uint16_t ir_rsv2; 00144 uint16_t ir_numgrps; 00145 struct igmp_grouprec ir_groups[1]; 00146 }; 00147 00151 #define IGMP_MINLEN 8 00152 00153 #define IGMP_MEMBERSHIP_QUERY 0x11 00154 #define IGMP_V1_MEMBERSHIP_REPORT 0x12 00155 #define IGMP_V2_MEMBERSHIP_REPORT 0x16 00156 #define IGMP_V3_MEMBERSHIP_REPORT 0x22 00157 #define IGMP_V2_LEAVE_GROUP 0x17 00162 #define IGMP_MAX_HOST_REPORT_DELAY 10 00163 00167 #define IGMP_TIMER_SCALE 10 00168 00173 #define IGMP_REPORT_MODE_IN 1 00174 #define IGMP_REPORT_MODE_EX 2 00175 #define IGMP_REPORT_TO_IN 3 00176 #define IGMP_REPORT_TO_EX 4 00177 #define IGMP_REPORT_ALLOW_NEW 5 00178 #define IGMP_REPORT_BLOCK_OLD 6 00180 00181 00185 #define IGMP_MASK_CUR_STATE 0x01 00186 #define IGMP_MASK_ALLOW_NEW 0x02 00187 #define IGMP_MASK_BLOCK_OLD 0x04 00188 #define IGMP_MASK_TO_IN 0x08 00189 #define IGMP_MASK_TO_EX 0x10 00190 #define IGMP_MASK_STATE_T1 0x20 00191 #define IGMP_MASK_STATE_T2 0x40 00192 #define IGMP_MASK_IF_STATE 0x80 00194 #define IGMP_MASK_STATE_TX (IGMP_MASK_STATE_T1 | IGMP_MASK_STATE_T2) 00195 #define IGMP_MASK_PENDING (IGMP_MASK_CUR_STATE | IGMP_MASK_ALLOW_NEW | IGMP_MASK_BLOCK_OLD) 00196 00201 #define IGMP_EXCLUDE_LIST 1 /* Exclude list used to tag report. */ 00202 #define IGMP_INCLUDE_LIST 2 /* Include list used to tag report. */ 00203 #define IGMP_RECORDED_LIST 3 /* Recorded list used to tag report. */ 00204 00205 00206 __BEGIN_DECLS 00207 /* Function prototypes */ 00208 extern void NutIgmpInput(NUTDEVICE * dev, NETBUF * nb); 00209 extern int NutIgmpOutput(uint8_t type, uint32_t dest, NETBUF * nb); 00210 00211 extern void NutIgmpJoinGroup(NUTDEVICE *dev, uint32_t ip_addr); 00212 extern void NutIgmpLeaveGroup(NUTDEVICE *dev, uint32_t ip_addr); 00213 00214 __END_DECLS 00215 /* End of prototypes */ 00217 #endif