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

Function in6_getaddr

tools/ifconfig/af_inet6.c:359–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359static void
360in6_getaddr(const char *s, int which)
361{
362 struct sockaddr_in6 *sin = sin6tab[which];
363#ifndef FSTACK
364 struct addrinfo hints, *res;
365 int error = -1;
366#endif
367
368 newaddr &= 1;
369
370 sin->sin6_len = sizeof(*sin);
371 if (which != MASK)
372 sin->sin6_family = AF_INET6;
373
374 if (which == ADDR) {
375 char *p = NULL;
376 if((p = strrchr(s, '/')) != NULL) {
377 *p = '\0';
378 in6_getprefix(p + 1, MASK);
379 explicit_prefix = 1;
380 }
381 }
382
383#ifdef FSTACK
384 if (inet_pton(AF_INET6_LINUX, s, &sin->sin6_addr) != 1)
385 errx(1, "%s: bad value", s);
386 return;
387#else
388 if (sin->sin6_family == AF_INET6) {
389 bzero(&hints, sizeof(struct addrinfo));
390 hints.ai_family = AF_INET6;
391 error = getaddrinfo(s, NULL, &hints, &res);
392 if (error != 0) {
393 if (inet_pton(AF_INET6, s, &sin->sin6_addr) != 1)
394 errx(1, "%s: bad value", s);
395 } else {
396 bcopy(res->ai_addr, sin, res->ai_addrlen);
397 freeaddrinfo(res);
398 }
399 }
400#endif
401}
402
403static int
404prefix(void *val, int size)

Callers

nothing calls this directly

Calls 6

strrchrFunction · 0.85
in6_getprefixFunction · 0.85
inet_ptonFunction · 0.85
bzeroFunction · 0.85
getaddrinfoFunction · 0.85
freeaddrinfoFunction · 0.85

Tested by

no test coverage detected