Lines Matching refs:ai
317 #define GET_AI(ai, afd, addr) \ argument
320 (ai) = get_ai(pai, (afd), (addr)); \
321 if ((ai) == NULL) { \
327 #define GET_PORT(ai, serv) \ argument
330 error = get_port((ai), (serv), 0); \
335 #define GET_CANONNAME(ai, str) \ argument
338 error = get_canonname(pai, (ai), (str)); \
357 freeaddrinfo(struct addrinfo *ai) in freeaddrinfo() argument
361 while (ai != NULL) { in freeaddrinfo()
362 next = ai->ai_next; in freeaddrinfo()
363 free(ai->ai_canonname); in freeaddrinfo()
365 free(ai); in freeaddrinfo()
366 ai = next; in freeaddrinfo()
395 struct addrinfo ai, ai0, *afai; in getaddrinfo() local
407 memset(&ai, 0, sizeof(ai)); in getaddrinfo()
414 pai = &ai; in getaddrinfo()
676 struct addrinfo *ai, **aip; in reorder() local
682 for (n = 0, ai = sentinel->ai_next; ai != NULL; ai = ai->ai_next, n++) in reorder()
703 for (i = 0, ai = sentinel->ai_next; i < n; ai = ai->ai_next, i++) { in reorder()
704 aio[i].aio_ai = ai; in reorder()
705 aio[i].aio_dstscope = gai_addr2scopetype(ai->ai_addr); in reorder()
706 aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr, in reorder()
848 struct addrinfo ai = *aio->aio_ai; in set_source() local
857 switch(ai.ai_family) { in set_source()
868 ai.ai_socktype = SOCK_DGRAM; in set_source()
869 ai.ai_protocol = IPPROTO_UDP; /* is UDP too specific? */ in set_source()
870 ai.ai_next = NULL; in set_source()
872 memcpy(&ss, ai.ai_addr, ai.ai_addrlen); in set_source()
873 ai.ai_addr = (struct sockaddr *)&ss; in set_source()
874 get_port(&ai, "1", 0); in set_source()
877 if ((s = _socket(ai.ai_family, ai.ai_socktype | SOCK_CLOEXEC, in set_source()
878 ai.ai_protocol)) < 0) in set_source()
881 if (ai.ai_family == AF_INET6) { in set_source()
882 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai.ai_addr; in set_source()
890 if (_connect(s, ai.ai_addr, ai.ai_addrlen) < 0) in set_source()
892 srclen = ai.ai_addrlen; in set_source()
901 if (ai.ai_family == AF_INET6) { in set_source()
906 memcpy(&ifr6.ifr_addr, ai.ai_addr, ai.ai_addrlen); in set_source()
1196 struct addrinfo *ai; in explore_null() local
1200 ai = NULL; in explore_null()
1221 GET_AI(ai, afd, afd->a_addrany); in explore_null()
1222 GET_PORT(ai, servname); in explore_null()
1224 GET_AI(ai, afd, afd->a_loopback); in explore_null()
1225 GET_PORT(ai, servname); in explore_null()
1228 *res = ai; in explore_null()
1232 if (ai != NULL) in explore_null()
1233 freeaddrinfo(ai); in explore_null()
1245 struct addrinfo *ai, ai0; in explore_numeric() local
1253 ai = NULL; in explore_numeric()
1299 GET_AI(ai, afd, p); in explore_numeric()
1300 GET_PORT(ai, servname); in explore_numeric()
1308 GET_CANONNAME(ai, canonname); in explore_numeric()
1318 *res = ai; in explore_numeric()
1323 if (ai != NULL) in explore_numeric()
1324 freeaddrinfo(ai); in explore_numeric()
1395 get_canonname(const struct addrinfo *pai, struct addrinfo *ai, const char *str) in get_canonname() argument
1398 ai->ai_canonname = strdup(str); in get_canonname()
1399 if (ai->ai_canonname == NULL) in get_canonname()
1409 struct addrinfo *ai; in get_ai() local
1420 ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) in get_ai()
1422 if (ai == NULL) in get_ai()
1425 memcpy(ai, pai, sizeof(struct addrinfo)); in get_ai()
1426 ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); in get_ai()
1427 memset(ai->ai_addr, 0, (size_t)afd->a_socklen); in get_ai()
1428 ai->ai_addr->sa_len = afd->a_socklen; in get_ai()
1429 ai->ai_addrlen = afd->a_socklen; in get_ai()
1430 if (ai->ai_family == PF_LOCAL) { in get_ai()
1433 ai->ai_addrlen -= afd->a_addrlen - n; in get_ai()
1434 ai->ai_addr->sa_len -= afd->a_addrlen - n; in get_ai()
1436 ai->ai_addr->sa_family = ai->ai_family = afd->a_af; in get_ai()
1437 p = (char *)(void *)(ai->ai_addr); in get_ai()
1439 return ai; in get_ai()
1446 struct addrinfo *ai; in copy_ai() local
1449 l = sizeof(*ai) + pai->ai_addrlen; in copy_ai()
1450 if ((ai = calloc(1, l)) == NULL) in copy_ai()
1452 memcpy(ai, pai, sizeof(*ai)); in copy_ai()
1453 ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); in copy_ai()
1454 memcpy(ai->ai_addr, pai->ai_addr, pai->ai_addrlen); in copy_ai()
1458 if ((ai->ai_canonname = malloc(l)) == NULL) { in copy_ai()
1459 free(ai); in copy_ai()
1462 strlcpy(ai->ai_canonname, pai->ai_canonname, l); in copy_ai()
1465 ai->ai_canonname = NULL; in copy_ai()
1468 ai->ai_next = NULL; in copy_ai()
1470 return ai; in copy_ai()
1474 get_portmatch(const struct addrinfo *ai, const char *servname) in get_portmatch() argument
1479 return get_port((struct addrinfo *)ai, servname, 1); in get_portmatch()
1483 get_port(struct addrinfo *ai, const char *servname, int matchonly) in get_port() argument
1492 switch (ai->ai_family) { in get_port()
1505 switch (ai->ai_socktype) { in get_port()
1514 switch (ai->ai_family) { in get_port()
1538 if (ai->ai_flags & AI_NUMERICSERV) in get_port()
1541 switch (ai->ai_protocol) { in get_port()
1565 switch (ai->ai_family) { in get_port()
1568 ai->ai_addr)->sin_port = port; in get_port()
1573 ai->ai_addr)->sin6_port = port; in get_port()
1805 struct addrinfo *ai, *cai; in addrinfo_marshal_func() local
1809 ai = *((struct addrinfo **)retval); in addrinfo_marshal_func()
1813 for (cai = ai; cai != NULL; cai = cai->ai_next) { in addrinfo_marshal_func()
1833 for (cai = ai; cai != NULL; cai = cai->ai_next) { in addrinfo_marshal_func()
1985 struct addrinfo ai; in getanswer() local
2141 ai = *pai; in getanswer()
2142 ai.ai_family = (type == T_A) ? AF_INET : AF_INET6; in getanswer()
2143 afd = find_afd(ai.ai_family); in getanswer()
2148 cur->ai_next = get_ai(&ai, afd, (const char *)cp); in getanswer()
2193 struct addrinfo *ai; member
2200 struct addrinfo *ai; in addr4sort() local
2209 for (ai = sentinel->ai_next; ai; ai = ai->ai_next) in addr4sort()
2216 for (ai = sentinel->ai_next; ai; ai = ai->ai_next) { in addr4sort()
2217 sin = (struct sockaddr_in *)ai->ai_addr; in addr4sort()
2223 addrs[i].ai = ai; in addr4sort()
2246 ai = sentinel; in addr4sort()
2248 ai->ai_next = addrs[i].ai; in addr4sort()
2249 ai = ai->ai_next; in addr4sort()
2251 ai->ai_next = NULL; in addr4sort()
2261 struct addrinfo *ai, ai0; in _dns_getaddrinfo() local
2269 ai = NULL; in _dns_getaddrinfo()
2350 ai = getanswer(buf2, q2.n, q2.name, q2.qtype, pai, res); in _dns_getaddrinfo()
2351 if (ai != NULL) { in _dns_getaddrinfo()
2352 cur->ai_next = ai; in _dns_getaddrinfo()
2357 if (ai == NULL || pai->ai_family != AF_UNSPEC || in _dns_getaddrinfo()
2359 ai = getanswer(buf, q.n, q.name, q.qtype, pai, res); in _dns_getaddrinfo()
2360 if (ai != NULL) in _dns_getaddrinfo()
2361 cur->ai_next = ai; in _dns_getaddrinfo()
2612 struct addrinfo *ai = NULL; in _yp_getaddrinfo() local
2632 ai = _yphostent(ypbuf, pai); in _yp_getaddrinfo()
2633 if (ai) { in _yp_getaddrinfo()
2634 cur->ai_next = ai; in _yp_getaddrinfo()
2641 if (ai != NULL) { in _yp_getaddrinfo()
2644 switch (ai->ai_family) { in _yp_getaddrinfo()
2648 sin6 = (struct sockaddr_in6 *)ai->ai_addr; in _yp_getaddrinfo()
2659 (ai == NULL || (pai->ai_flags & AI_ALL) == AI_ALL))) { in _yp_getaddrinfo()
2668 ai = _yphostent(ypbuf, &ai4); in _yp_getaddrinfo()
2669 if (ai) { in _yp_getaddrinfo()
2670 cur->ai_next = ai; in _yp_getaddrinfo()