mld6.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*-
  2. * SPDX-License-Identifier: BSD-3-Clause
  3. *
  4. * Copyright (c) 2009 Bruce Simpson.
  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. * 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. The name of the author may not be used to endorse or promote
  15. * products derived from this software without specific prior written
  16. * permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * $FreeBSD$
  31. */
  32. #ifndef _NETINET6_MLD6_H_
  33. #define _NETINET6_MLD6_H_
  34. /*
  35. * Multicast Listener Discovery (MLD) definitions.
  36. */
  37. /* Minimum length of any MLD protocol message. */
  38. #define MLD_MINLEN sizeof(struct icmp6_hdr)
  39. /*
  40. * MLD v2 query format.
  41. * See <netinet/icmp6.h> for struct mld_hdr
  42. * (MLDv1 query and host report format).
  43. */
  44. struct mldv2_query {
  45. struct icmp6_hdr mld_icmp6_hdr; /* ICMPv6 header */
  46. struct in6_addr mld_addr; /* address being queried */
  47. uint8_t mld_misc; /* reserved/suppress/robustness */
  48. uint8_t mld_qqi; /* querier's query interval */
  49. uint16_t mld_numsrc; /* number of sources */
  50. /* followed by 1..numsrc source addresses */
  51. } __packed;
  52. #define MLD_V2_QUERY_MINLEN sizeof(struct mldv2_query)
  53. #define MLD_MRC_EXP(x) ((ntohs((x)) >> 12) & 0x0007)
  54. #define MLD_MRC_MANT(x) (ntohs((x)) & 0x0fff)
  55. #define MLD_QQIC_EXP(x) (((x) >> 4) & 0x07)
  56. #define MLD_QQIC_MANT(x) ((x) & 0x0f)
  57. #define MLD_QRESV(x) (((x) >> 4) & 0x0f)
  58. #define MLD_SFLAG(x) (((x) >> 3) & 0x01)
  59. #define MLD_QRV(x) ((x) & 0x07)
  60. /*
  61. * MLDv2 host membership report header.
  62. * mld_type: MLDV2_LISTENER_REPORT
  63. */
  64. struct mldv2_report {
  65. struct icmp6_hdr mld_icmp6_hdr;
  66. /* followed by 1..numgrps records */
  67. } __packed;
  68. /* overlaid on struct icmp6_hdr. */
  69. #define mld_numrecs mld_icmp6_hdr.icmp6_data16[1]
  70. struct mldv2_record {
  71. uint8_t mr_type; /* record type */
  72. uint8_t mr_datalen; /* length of auxiliary data */
  73. uint16_t mr_numsrc; /* number of sources */
  74. struct in6_addr mr_addr; /* address being reported */
  75. /* followed by 1..numsrc source addresses */
  76. } __packed;
  77. #define MLD_V2_REPORT_MAXRECS 65535
  78. /*
  79. * MLDv2 report modes.
  80. */
  81. #define MLD_DO_NOTHING 0 /* don't send a record */
  82. #define MLD_MODE_IS_INCLUDE 1 /* MODE_IN */
  83. #define MLD_MODE_IS_EXCLUDE 2 /* MODE_EX */
  84. #define MLD_CHANGE_TO_INCLUDE_MODE 3 /* TO_IN */
  85. #define MLD_CHANGE_TO_EXCLUDE_MODE 4 /* TO_EX */
  86. #define MLD_ALLOW_NEW_SOURCES 5 /* ALLOW_NEW */
  87. #define MLD_BLOCK_OLD_SOURCES 6 /* BLOCK_OLD */
  88. /*
  89. * MLDv2 query types.
  90. */
  91. #define MLD_V2_GENERAL_QUERY 1
  92. #define MLD_V2_GROUP_QUERY 2
  93. #define MLD_V2_GROUP_SOURCE_QUERY 3
  94. /*
  95. * Maximum report interval for MLDv1 host membership reports.
  96. */
  97. #define MLD_V1_MAX_RI 10
  98. /*
  99. * MLD_TIMER_SCALE denotes that the MLD code field specifies
  100. * time in milliseconds.
  101. */
  102. #define MLD_TIMER_SCALE 1000
  103. #endif /* _NETINET6_MLD6_H_ */