MCPcopy Create free account
hub / github.com/F-Stack/f-stack / in6_mask2len

Function in6_mask2len

freebsd/netinet6/in6.c:201–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201int
202in6_mask2len(struct in6_addr *mask, u_char *lim0)
203{
204 int x = 0, y;
205 u_char *lim = lim0, *p;
206
207 /* ignore the scope_id part */
208 if (lim0 == NULL || lim0 - (u_char *)mask > sizeof(*mask))
209 lim = (u_char *)mask + sizeof(*mask);
210 for (p = (u_char *)mask; p < lim; x++, p++) {
211 if (*p != 0xff)
212 break;
213 }
214 y = 0;
215 if (p < lim) {
216 for (y = 0; y < 8; y++) {
217 if ((*p & (0x80 >> y)) == 0)
218 break;
219 }
220 }
221
222 /*
223 * when the limit pointer is given, do a stricter check on the
224 * remaining bits.
225 */
226 if (p < lim) {
227 if (y != 0 && (*p & (0x00ff >> y)) != 0)
228 return (-1);
229 for (p = p + 1; p < lim; p++)
230 if (*p != 0)
231 return (-1);
232 }
233
234 return x * 8 + y;
235}
236
237#ifdef COMPAT_FREEBSD32
238struct in6_ndifreq32 {

Callers 6

in6_controlFunction · 0.85
in6_validate_ifraFunction · 0.85
ifa_is_p2pFunction · 0.85
in6_src_ioctlFunction · 0.85
in6_ifattach_linklocalFunction · 0.85
in6_ifaddFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected