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

Function in6_getprefix

tools/ifconfig/af_inet6.c:337–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335};
336
337static void
338in6_getprefix(const char *plen, int which)
339{
340 struct sockaddr_in6 *sin = sin6tab[which];
341 u_char *cp;
342 int len = atoi(plen);
343
344 if ((len < 0) || (len > 128))
345 errx(1, "%s: bad value", plen);
346 sin->sin6_len = sizeof(*sin);
347 if (which != MASK)
348 sin->sin6_family = AF_INET6;
349 if ((len == 0) || (len == 128)) {
350 memset(&sin->sin6_addr, 0xff, sizeof(struct in6_addr));
351 return;
352 }
353 memset((void *)&sin->sin6_addr, 0x00, sizeof(sin->sin6_addr));
354 for (cp = (u_char *)&sin->sin6_addr; len > 7; len -= 8)
355 *cp++ = 0xff;
356 *cp = 0xff << (8 - len);
357}
358
359static void
360in6_getaddr(const char *s, int which)

Callers 1

in6_getaddrFunction · 0.85

Calls 1

memsetFunction · 0.85

Tested by

no test coverage detected