igmp.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #ifndef _NETINET_IGMP_H_
  2. #define _NETINET_IGMP_H_
  3. /*
  4. * Copyright (C) 2007 by egnite Software GmbH. 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. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * -
  35. * Copyright (c) 1988 Stephen Deering.
  36. * Copyright (c) 1992, 1993
  37. * The Regents of the University of California. All rights reserved.
  38. *
  39. * Redistribution and use in source and binary forms, with or without
  40. * modification, are permitted provided that the following conditions
  41. * are met:
  42. * 1. Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * 2. Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in the
  46. * documentation and/or other materials provided with the distribution.
  47. * 3. Neither the name of the University nor the names of its contributors
  48. * may be used to endorse or promote products derived from this software
  49. * without specific prior written permission.
  50. *
  51. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  52. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  53. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  54. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  55. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  56. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  57. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  58. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  59. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  60. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  61. * SUCH DAMAGE.
  62. */
  63. /*
  64. * $Log: igmp.h,v $
  65. * Revision 1.1 2007/05/02 11:18:32 haraldkipp
  66. * IGMP support added. Incomplete.
  67. *
  68. */
  69. #include <sys/types.h>
  70. #include <dev/netbuf.h>
  71. #include <net/if_var.h>
  72. /*!
  73. * \file netinet/igmp.h
  74. * \brief IGMP protocol definitions.
  75. */
  76. /*!
  77. * \addtogroup xgIgmp
  78. */
  79. /*@{*/
  80. /*!
  81. * \typedef IGMP
  82. * \brief IGMP packet type.
  83. */
  84. typedef struct __attribute__ ((packed))
  85. igmp IGMP;
  86. /*!
  87. * \struct igmp igmp.h netinet/igmp.h
  88. * \brief IGMP packet structure.
  89. */
  90. struct __attribute__ ((packed)) igmp
  91. {
  92. u_char igmp_type; /*!< \brief Version and type of IGMP message. */
  93. u_char igmp_code; /*!< \brief Subtype for routing messages. */
  94. u_short igmp_cksum; /*!< \brief IP-style checksum. */
  95. u_long igmp_group; /*!< \brief Group address being reported. */
  96. };
  97. /*!
  98. * \brief IGMPv3 query format
  99. */
  100. struct __attribute__ ((packed)) igmpv3 {
  101. u_char igmp_type; /*!< \brief Version and type of IGMP message. */
  102. u_char igmp_code; /*!< \brief Subtype for routing messages. */
  103. u_short igmp_cksum; /*!< \brief IP-style checksum. */
  104. u_long igmp_group; /*!< \brief Group address being reported. */
  105. u_char igmp_misc; /*!< \brief Reserved, supress and robustness var. */
  106. u_char igmp_qqi; /*!< \brief Querier's query interval. */
  107. u_short igmp_numsrc; /*!< \brief Number of sources. */
  108. u_long igmp_sources[1]; /*!< \brief Source addresses. */
  109. };
  110. /*!
  111. * \brief IGMPv3 group record.
  112. */
  113. struct __attribute__ ((packed)) igmp_grouprec {
  114. u_char ig_type; /*!< \brief Record type. */
  115. u_char ig_datalen; /*!< \brief Amount of aux data. */
  116. u_short ig_numsrc; /*!< \brief Number of sources. */
  117. u_long ig_group; /*!< \brief The group being reported. */
  118. u_long ig_sources[1]; /*!< \brief Source addresses. */
  119. };
  120. /*!
  121. * \brief IGMPv3 report.
  122. */
  123. struct __attribute__ ((packed)) igmp_report {
  124. u_char ir_type; /*!< \brief Record type. */
  125. u_char ir_rsv1; /*!< \brief Reserved. */
  126. u_short ir_cksum; /*!< \brief Checksum. */
  127. u_short ir_rsv2; /*!< \brief Reserved. */
  128. u_short ir_numgrps; /*!< \brief Number of group records. */
  129. struct igmp_grouprec ir_groups[1]; /*!< \brief Group records. */
  130. };
  131. /*!
  132. * \brief Minimum IGMP packet length.
  133. */
  134. #define IGMP_MINLEN 8
  135. #define IGMP_MEMBERSHIP_QUERY 0x11 /*!< \brief Membership query. */
  136. #define IGMP_V1_MEMBERSHIP_REPORT 0x12 /*!< \brief Ver. 1 membership report. */
  137. #define IGMP_V2_MEMBERSHIP_REPORT 0x16 /*!< \brief Ver. 2 membership report. */
  138. #define IGMP_V3_MEMBERSHIP_REPORT 0x22 /*!< \brief Ver. 3 membership report. */
  139. #define IGMP_V2_LEAVE_GROUP 0x17 /*!< \brief Leave-group message. */
  140. /*!
  141. * \brief Maximum delay for response query.
  142. */
  143. #define IGMP_MAX_HOST_REPORT_DELAY 10
  144. /*!
  145. * \brief Code field time scale.
  146. */
  147. #define IGMP_TIMER_SCALE 10
  148. /*!
  149. * \name IGMPv3 Report Types
  150. */
  151. /*@{*/
  152. #define IGMP_REPORT_MODE_IN 1 /*!< \brief Mode-is-include. */
  153. #define IGMP_REPORT_MODE_EX 2 /*!< \brief Mode-is-exclude. */
  154. #define IGMP_REPORT_TO_IN 3 /*!< \brief Change-to-include. */
  155. #define IGMP_REPORT_TO_EX 4 /*!< \brief Change-to-exclude. */
  156. #define IGMP_REPORT_ALLOW_NEW 5 /*!< \brief Allow-new-sources. */
  157. #define IGMP_REPORT_BLOCK_OLD 6 /*!< \brief Block-old-sources. */
  158. /*@}*/
  159. /*!
  160. * \name IGMPv3 Report Type Flags
  161. */
  162. /*@{*/
  163. #define IGMP_MASK_CUR_STATE 0x01 /*!< \brief Report current-state. */
  164. #define IGMP_MASK_ALLOW_NEW 0x02 /*!< \brief Report source as allow-new. */
  165. #define IGMP_MASK_BLOCK_OLD 0x04 /*!< \brief Report source as block-old. */
  166. #define IGMP_MASK_TO_IN 0x08 /*!< \brief Report source as to_in. */
  167. #define IGMP_MASK_TO_EX 0x10 /*!< \brief Report source as to_ex. */
  168. #define IGMP_MASK_STATE_T1 0x20 /*!< \brief State at T1. */
  169. #define IGMP_MASK_STATE_T2 0x40 /*!< \brief State at T2. */
  170. #define IGMP_MASK_IF_STATE 0x80 /*!< \brief Report current-state per interface. */
  171. #define IGMP_MASK_STATE_TX (IGMP_MASK_STATE_T1 | IGMP_MASK_STATE_T2)
  172. #define IGMP_MASK_PENDING (IGMP_MASK_CUR_STATE | IGMP_MASK_ALLOW_NEW | IGMP_MASK_BLOCK_OLD)
  173. /*@}*/
  174. /*!
  175. * \brief List identifiers
  176. */
  177. #define IGMP_EXCLUDE_LIST 1 /* Exclude list used to tag report. */
  178. #define IGMP_INCLUDE_LIST 2 /* Include list used to tag report. */
  179. #define IGMP_RECORDED_LIST 3 /* Recorded list used to tag report. */
  180. __BEGIN_DECLS
  181. /* Function prototypes */
  182. extern void NutIgmpInput(NUTDEVICE * dev, NETBUF * nb);
  183. extern int NutIgmpOutput(u_char type, u_long dest, NETBUF * nb);
  184. __END_DECLS
  185. /* End of prototypes */
  186. /*@}*/
  187. #endif