]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_util.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2008 Everton da Silva Marques
16 RFC 3376: 4.1.7. QQIC (Querier's Query Interval Code)
18 If QQIC < 128, QQI = QQIC
19 If QQIC >= 128, QQI = (mant | 0x10) << (exp + 3)
26 Since exp=0..7 then (exp+3)=3..10, then QQI has
27 one of the following bit patterns:
29 exp=0: QQI = 0000.0000.1MMM.M000
30 exp=1: QQI = 0000.0001.MMMM.0000
32 exp=6: QQI = 001M.MMM0.0000.0000
33 exp=7: QQI = 01MM.MM00.0000.0000
37 uint8_t igmp_msg_encode16to8(uint16_t value
)
44 uint16_t mask
= 0x4000;
47 for (exp
= 7; exp
> 0; --exp
) {
52 mant
= 0x000F & (value
>> (exp
+ 3));
53 code
= ((uint8_t)1 << 7) | ((uint8_t)exp
<< 4) | (uint8_t)mant
;
60 RFC 3376: 4.1.7. QQIC (Querier's Query Interval Code)
62 If QQIC < 128, QQI = QQIC
63 If QQIC >= 128, QQI = (mant | 0x10) << (exp + 3)
70 uint16_t igmp_msg_decode8to16(uint8_t code
)
77 uint16_t mant
= (code
& 0x0F);
78 uint8_t exp
= (code
& 0x70) >> 4;
79 value
= (mant
| 0x10) << (exp
+ 3);
85 void pim_pkt_dump(const char *label
, const uint8_t *buf
, int size
)
87 zlog_debug("%s: pkt dump size=%d", label
, size
);
88 zlog_hexdump(buf
, size
);
91 int pim_is_group_224_0_0_0_24(struct in_addr group_addr
)
94 static struct prefix group_224
;
98 if (!str2prefix("224.0.0.0/24", &group_224
))
103 group
.family
= AF_INET
;
104 group
.u
.prefix4
= group_addr
;
105 group
.prefixlen
= IPV4_MAX_BITLEN
;
107 return prefix_match(&group_224
, &group
);
110 int pim_is_group_224_4(struct in_addr group_addr
)
112 static int first
= 1;
113 static struct prefix group_all
;
117 if (!str2prefix("224.0.0.0/4", &group_all
))
122 group
.family
= AF_INET
;
123 group
.u
.prefix4
= group_addr
;
124 group
.prefixlen
= IPV4_MAX_BITLEN
;
126 return prefix_match(&group_all
, &group
);
129 bool pim_is_group_filtered(struct pim_interface
*pim_ifp
, pim_addr
*grp
)
131 struct prefix grp_pfx
;
132 struct prefix_list
*pl
;
134 if (!pim_ifp
->boundary_oil_plist
)
137 pim_addr_to_prefix(&grp_pfx
, *grp
);
139 pl
= prefix_list_lookup(PIM_AFI
, pim_ifp
->boundary_oil_plist
);
140 return pl
? prefix_list_apply_ext(pl
, NULL
, &grp_pfx
, true) ==
146 /* This function returns all multicast group */
147 int pim_get_all_mcast_group(struct prefix
*prefix
)
150 if (!str2prefix("224.0.0.0/4", prefix
))
153 if (!str2prefix("FF00::0/8", prefix
))
159 bool pim_addr_is_multicast(pim_addr addr
)
162 if (IN_MULTICAST(ntohl(addr
.s_addr
)))
165 if (IN6_IS_ADDR_MULTICAST(&addr
))