Lines Matching refs:ai
177 #define GET_AI(ai, afd, addr) \ argument
180 (ai) = get_ai(pai, (afd), (addr)); \
181 if ((ai) == NULL) { \
187 #define GET_PORT(ai, serv) \ argument
190 error = get_port((ai), (serv), 0); \
203 void freeaddrinfo(struct addrinfo* ai) { in freeaddrinfo() argument
204 while (ai) { in freeaddrinfo()
205 struct addrinfo* next = ai->ai_next; in freeaddrinfo()
206 if (ai->ai_canonname) free(ai->ai_canonname); in freeaddrinfo()
208 free(ai); in freeaddrinfo()
209 ai = next; in freeaddrinfo()
285 struct addrinfo ai = { in android_getaddrinfofornetcontext() local
318 ai = *hints; in android_getaddrinfofornetcontext()
324 if (ai.ai_socktype != ANY && ai.ai_protocol != ANY) { in android_getaddrinfofornetcontext()
326 if (ai.ai_family != ex.e_af) continue; in android_getaddrinfofornetcontext()
329 if (ai.ai_socktype == ex.e_socktype && ai.ai_protocol != ex.e_protocol) { in android_getaddrinfofornetcontext()
343 if (MATCH_FAMILY(ai.ai_family, PF_INET, 1) || MATCH_FAMILY(ai.ai_family, PF_INET6, 1)) { in android_getaddrinfofornetcontext()
344 struct addrinfo tmp = ai; in android_getaddrinfofornetcontext()
357 if (!MATCH_FAMILY(ai.ai_family, ex.e_af, WILD_AF(ex))) continue; in android_getaddrinfofornetcontext()
358 if (!MATCH(ai.ai_socktype, ex.e_socktype, WILD_SOCKTYPE(ex))) continue; in android_getaddrinfofornetcontext()
359 if (!MATCH(ai.ai_protocol, ex.e_protocol, WILD_PROTOCOL(ex))) continue; in android_getaddrinfofornetcontext()
361 struct addrinfo tmp = ai; in android_getaddrinfofornetcontext()
390 if (ai.ai_flags & AI_NUMERICHOST) { in android_getaddrinfofornetcontext()
401 if (ai.ai_family != ex.e_af) continue; in android_getaddrinfofornetcontext()
403 if (!MATCH(ai.ai_socktype, ex.e_socktype, WILD_SOCKTYPE(ex))) { in android_getaddrinfofornetcontext()
406 if (!MATCH(ai.ai_protocol, ex.e_protocol, WILD_PROTOCOL(ex))) { in android_getaddrinfofornetcontext()
410 struct addrinfo tmp = ai; in android_getaddrinfofornetcontext()
646 static int get_canonname(const struct addrinfo* pai, struct addrinfo* ai, const char* str) { in get_canonname() argument
648 assert(ai != NULL); in get_canonname()
652 ai->ai_canonname = strdup(str); in get_canonname()
653 if (ai->ai_canonname == NULL) return EAI_MEMORY; in get_canonname()
661 struct addrinfo* ai; in get_ai() local
667 ai = (struct addrinfo*) malloc(sizeof(struct addrinfo) + sizeof(sockaddr_union)); in get_ai()
668 if (ai == NULL) return NULL; in get_ai()
670 memcpy(ai, pai, sizeof(struct addrinfo)); in get_ai()
671 ai->ai_addr = (struct sockaddr*) (void*) (ai + 1); in get_ai()
672 memset(ai->ai_addr, 0, sizeof(sockaddr_union)); in get_ai()
674 ai->ai_addrlen = afd->a_socklen; in get_ai()
675 ai->ai_addr->sa_family = ai->ai_family = afd->a_af; in get_ai()
676 p = (char*) (void*) (ai->ai_addr); in get_ai()
678 return ai; in get_ai()
681 static int get_portmatch(const struct addrinfo* ai, const char* servname) { in get_portmatch() argument
682 assert(ai != NULL); in get_portmatch()
685 return get_port(ai, servname, 1); in get_portmatch()
688 static int get_port(const struct addrinfo* ai, const char* servname, int matchonly) { in get_port() argument
694 assert(ai != NULL); in get_port()
698 switch (ai->ai_family) { in get_port()
706 switch (ai->ai_socktype) { in get_port()
726 if (ai->ai_flags & AI_NUMERICSERV) return EAI_NONAME; in get_port()
728 switch (ai->ai_socktype) { in get_port()
745 switch (ai->ai_family) { in get_port()
747 ((struct sockaddr_in*) (void*) ai->ai_addr)->sin_port = port; in get_port()
750 ((struct sockaddr_in6*) (void*) ai->ai_addr)->sin6_port = port; in get_port()
832 struct addrinfo ai; in getanswer() local
984 ai = *pai; in getanswer()
985 ai.ai_family = (type == T_A) ? AF_INET : AF_INET6; in getanswer()
986 afd = find_afd(ai.ai_family); in getanswer()
991 cur->ai_next = get_ai(&ai, afd, (const char*) cp); in getanswer()
1015 struct addrinfo* ai; member
1193 scope_dst1 = _get_scope(a1->ai->ai_addr); in _rfc6724_compare()
1197 scope_dst2 = _get_scope(a2->ai->ai_addr); in _rfc6724_compare()
1216 label_dst1 = _get_label(a1->ai->ai_addr); in _rfc6724_compare()
1220 label_dst2 = _get_label(a2->ai->ai_addr); in _rfc6724_compare()
1228 precedence1 = _get_precedence(a1->ai->ai_addr); in _rfc6724_compare()
1229 precedence2 = _get_precedence(a2->ai->ai_addr); in _rfc6724_compare()
1250 if (a1->has_src_addr && a1->ai->ai_addr->sa_family == AF_INET6 && a2->has_src_addr && in _rfc6724_compare()
1251 a2->ai->ai_addr->sa_family == AF_INET6) { in _rfc6724_compare()
1253 const struct sockaddr_in6* a1_dst = (const struct sockaddr_in6*) a1->ai->ai_addr; in _rfc6724_compare()
1255 const struct sockaddr_in6* a2_dst = (const struct sockaddr_in6*) a2->ai->ai_addr; in _rfc6724_compare()
1358 elems[i].ai = cur; in _rfc6724_sort()
1371 list_sentinel->ai_next = elems[0].ai; in _rfc6724_sort()
1373 elems[i].ai->ai_next = elems[i + 1].ai; in _rfc6724_sort()
1375 elems[nelem - 1].ai->ai_next = NULL; in _rfc6724_sort()
1456 addrinfo* ai = getanswer(buf.get(), q.n, q.name, q.qtype, pai, &he); in dns_getaddrinfo() local
1457 if (ai) { in dns_getaddrinfo()
1458 cur->ai_next = ai; in dns_getaddrinfo()
1462 ai = getanswer(buf2.get(), q2.n, q2.name, q2.qtype, pai, &he); in dns_getaddrinfo()
1463 if (ai) cur->ai_next = ai; in dns_getaddrinfo()