mld.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef LINUX_MLD_H
  2. #define LINUX_MLD_H
  3. #include <linux/in6.h>
  4. #include <linux/icmpv6.h>
  5. /* MLDv1 Query/Report/Done */
  6. struct mld_msg {
  7. struct icmp6hdr mld_hdr;
  8. struct in6_addr mld_mca;
  9. };
  10. #define mld_type mld_hdr.icmp6_type
  11. #define mld_code mld_hdr.icmp6_code
  12. #define mld_cksum mld_hdr.icmp6_cksum
  13. #define mld_maxdelay mld_hdr.icmp6_maxdelay
  14. #define mld_reserved mld_hdr.icmp6_dataun.un_data16[1]
  15. /* Multicast Listener Discovery version 2 headers */
  16. /* MLDv2 Report */
  17. struct mld2_grec {
  18. __u8 grec_type;
  19. __u8 grec_auxwords;
  20. __be16 grec_nsrcs;
  21. struct in6_addr grec_mca;
  22. struct in6_addr grec_src[0];
  23. };
  24. struct mld2_report {
  25. struct icmp6hdr mld2r_hdr;
  26. struct mld2_grec mld2r_grec[0];
  27. };
  28. #define mld2r_type mld2r_hdr.icmp6_type
  29. #define mld2r_resv1 mld2r_hdr.icmp6_code
  30. #define mld2r_cksum mld2r_hdr.icmp6_cksum
  31. #define mld2r_resv2 mld2r_hdr.icmp6_dataun.un_data16[0]
  32. #define mld2r_ngrec mld2r_hdr.icmp6_dataun.un_data16[1]
  33. /* MLDv2 Query */
  34. struct mld2_query {
  35. struct icmp6hdr mld2q_hdr;
  36. struct in6_addr mld2q_mca;
  37. #if defined(__LITTLE_ENDIAN_BITFIELD)
  38. __u8 mld2q_qrv:3,
  39. mld2q_suppress:1,
  40. mld2q_resv2:4;
  41. #elif defined(__BIG_ENDIAN_BITFIELD)
  42. __u8 mld2q_resv2:4,
  43. mld2q_suppress:1,
  44. mld2q_qrv:3;
  45. #else
  46. #error "Please fix <asm/byteorder.h>"
  47. #endif
  48. __u8 mld2q_qqic;
  49. __be16 mld2q_nsrcs;
  50. struct in6_addr mld2q_srcs[0];
  51. };
  52. #define mld2q_type mld2q_hdr.icmp6_type
  53. #define mld2q_code mld2q_hdr.icmp6_code
  54. #define mld2q_cksum mld2q_hdr.icmp6_cksum
  55. #define mld2q_mrc mld2q_hdr.icmp6_maxdelay
  56. #define mld2q_resv1 mld2q_hdr.icmp6_dataun.un_data16[1]
  57. /* Max Response Code */
  58. #define MLDV2_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
  59. #define MLDV2_EXP(thresh, nbmant, nbexp, value) \
  60. ((value) < (thresh) ? (value) : \
  61. ((MLDV2_MASK(value, nbmant) | (1<<(nbmant))) << \
  62. (MLDV2_MASK((value) >> (nbmant), nbexp) + (nbexp))))
  63. #define MLDV2_MRC(value) MLDV2_EXP(0x8000, 12, 3, value)
  64. #endif