igmp_proto.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file igmp_proto.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions 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 author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * @section DESCRIPTION
  30. *
  31. * Definitions for the IGMP protocol.
  32. */
  33. #ifndef BADVPN_MISC_IGMP_PROTO_H
  34. #define BADVPN_MISC_IGMP_PROTO_H
  35. #include <stdint.h>
  36. #include <misc/packed.h>
  37. #define IGMP_TYPE_MEMBERSHIP_QUERY 0x11
  38. #define IGMP_TYPE_V1_MEMBERSHIP_REPORT 0x12
  39. #define IGMP_TYPE_V2_MEMBERSHIP_REPORT 0x16
  40. #define IGMP_TYPE_V3_MEMBERSHIP_REPORT 0x22
  41. #define IGMP_TYPE_V2_LEAVE_GROUP 0x17
  42. #define IGMP_RECORD_TYPE_MODE_IS_INCLUDE 1
  43. #define IGMP_RECORD_TYPE_MODE_IS_EXCLUDE 2
  44. #define IGMP_RECORD_TYPE_CHANGE_TO_INCLUDE_MODE 3
  45. #define IGMP_RECORD_TYPE_CHANGE_TO_EXCLUDE_MODE 4
  46. B_START_PACKED
  47. struct igmp_source {
  48. uint32_t addr;
  49. } B_PACKED;
  50. B_END_PACKED
  51. B_START_PACKED
  52. struct igmp_base {
  53. uint8_t type;
  54. uint8_t max_resp_code;
  55. uint16_t checksum;
  56. } B_PACKED;
  57. B_END_PACKED
  58. B_START_PACKED
  59. struct igmp_v3_query_extra {
  60. uint32_t group;
  61. uint8_t reserved4_suppress1_qrv3;
  62. uint8_t qqic;
  63. uint16_t number_of_sources;
  64. } B_PACKED;
  65. B_END_PACKED
  66. B_START_PACKED
  67. struct igmp_v3_report_extra {
  68. uint16_t reserved;
  69. uint16_t number_of_group_records;
  70. } B_PACKED;
  71. B_END_PACKED
  72. B_START_PACKED
  73. struct igmp_v3_report_record {
  74. uint8_t type;
  75. uint8_t aux_data_len;
  76. uint16_t number_of_sources;
  77. uint32_t group;
  78. } B_PACKED;
  79. B_END_PACKED
  80. B_START_PACKED
  81. struct igmp_v2_extra {
  82. uint32_t group;
  83. } B_PACKED;
  84. B_END_PACKED
  85. #endif