1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/icmpv6.h>
8 /* MLDv1 Query/Report/Done */
10 struct icmp6hdr mld_hdr
;
11 struct in6_addr mld_mca
;
14 #define mld_type mld_hdr.icmp6_type
15 #define mld_code mld_hdr.icmp6_code
16 #define mld_cksum mld_hdr.icmp6_cksum
17 #define mld_maxdelay mld_hdr.icmp6_maxdelay
18 #define mld_reserved mld_hdr.icmp6_dataun.un_data16[1]
20 /* Multicast Listener Discovery version 2 headers */
26 struct in6_addr grec_mca
;
27 struct in6_addr grec_src
[0];
31 struct icmp6hdr mld2r_hdr
;
32 struct mld2_grec mld2r_grec
[0];
35 #define mld2r_type mld2r_hdr.icmp6_type
36 #define mld2r_resv1 mld2r_hdr.icmp6_code
37 #define mld2r_cksum mld2r_hdr.icmp6_cksum
38 #define mld2r_resv2 mld2r_hdr.icmp6_dataun.un_data16[0]
39 #define mld2r_ngrec mld2r_hdr.icmp6_dataun.un_data16[1]
43 struct icmp6hdr mld2q_hdr
;
44 struct in6_addr mld2q_mca
;
45 #if defined(__LITTLE_ENDIAN_BITFIELD)
49 #elif defined(__BIG_ENDIAN_BITFIELD)
54 #error "Please fix <asm/byteorder.h>"
58 struct in6_addr mld2q_srcs
[0];
61 #define mld2q_type mld2q_hdr.icmp6_type
62 #define mld2q_code mld2q_hdr.icmp6_code
63 #define mld2q_cksum mld2q_hdr.icmp6_cksum
64 #define mld2q_mrc mld2q_hdr.icmp6_maxdelay
65 #define mld2q_resv1 mld2q_hdr.icmp6_dataun.un_data16[1]
67 /* RFC3810, 5.1.3. Maximum Response Code:
69 * If Maximum Response Code >= 32768, Maximum Response Code represents a
70 * floating-point value as follows:
72 * 0 1 2 3 4 5 6 7 8 9 A B C D E F
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 #define MLDV2_MRC_EXP(value) (((value) >> 12) & 0x0007)
78 #define MLDV2_MRC_MAN(value) ((value) & 0x0fff)
80 /* RFC3810, 5.1.9. QQIC (Querier's Query Interval Code):
82 * If QQIC >= 128, QQIC represents a floating-point value as follows:
89 #define MLDV2_QQIC_EXP(value) (((value) >> 4) & 0x07)
90 #define MLDV2_QQIC_MAN(value) ((value) & 0x0f)
92 #define MLD_EXP_MIN_LIMIT 32768UL
93 #define MLDV1_MRD_MAX_COMPAT (MLD_EXP_MIN_LIMIT - 1)
95 static inline unsigned long mldv2_mrc(const struct mld2_query
*mlh2
)
97 /* RFC3810, 5.1.3. Maximum Response Code */
98 unsigned long ret
, mc_mrc
= ntohs(mlh2
->mld2q_mrc
);
100 if (mc_mrc
< MLD_EXP_MIN_LIMIT
) {
103 unsigned long mc_man
, mc_exp
;
105 mc_exp
= MLDV2_MRC_EXP(mc_mrc
);
106 mc_man
= MLDV2_MRC_MAN(mc_mrc
);
108 ret
= (mc_man
| 0x1000) << (mc_exp
+ 3);