genericopenlibs/openenvcore/libc/src/net/getaddrinfo.c
branchRCL_3
changeset 60 82ca0c6a68ed
parent 57 2efc27d87e1c
equal deleted inserted replaced
57:2efc27d87e1c 60:82ca0c6a68ed
  1744         {
  1744         {
  1745         struct addrinfo *resNative;
  1745         struct addrinfo *resNative;
  1746         struct addrinfo *currNative;
  1746         struct addrinfo *currNative;
  1747         int haveV6asV4 = 0;
  1747         int haveV6asV4 = 0;
  1748         int haveV4asV6 = 0;
  1748         int haveV4asV6 = 0;
       
  1749         int haverealv4 = 0;
  1749         /* Get the list of addresses using the native api */
  1750         /* Get the list of addresses using the native api */
  1750         int ret = getaddrinfo_private(hostname, pai, &resNative);
  1751         int ret = getaddrinfo_private(hostname, pai, &resNative);
  1751         if (ret != 0)
  1752         if (ret != 0)
  1752             {
  1753             {
  1753             ERR(ret);
  1754             ERR(ret);
  1774                         {
  1775                         {
  1775                         GET_CANONNAME(cur->ai_next, currNative->ai_canonname);
  1776                         GET_CANONNAME(cur->ai_next, currNative->ai_canonname);
  1776                         }
  1777                         }
  1777 
  1778 
  1778                     cur = cur->ai_next;
  1779                     cur = cur->ai_next;
       
  1780                     haverealv4 = 1;
  1779                     }
  1781                     }
  1780                 }
  1782                 }
  1781 
  1783 
  1782             if (currNative->ai_family == PF_INET6 && (hints->ai_family == PF_INET6 || hints->ai_family == PF_UNSPEC))
  1784             if (currNative->ai_family == PF_INET6 && (hints->ai_family == PF_INET6 || hints->ai_family == PF_UNSPEC))
  1783                 {
  1785                 {
  1830                 }
  1832                 }
  1831             }
  1833             }
  1832         
  1834         
  1833         if (haveV6asV4)
  1835         if (haveV6asV4)
  1834             {
  1836             {
  1835             if ((hints->ai_family == PF_INET && !sentinel.ai_next) || (hints->ai_flags & (AI_V4MAPPED|AI_ALL)))
  1837             if ((hints->ai_family == PF_INET && !sentinel.ai_next) || (hints->ai_family == PF_UNSPEC && !haverealv4) || (hints->ai_flags & (AI_V4MAPPED|AI_ALL)))
  1836                 {
  1838                 {
  1837                 currNative = resNative;
  1839                 currNative = resNative;
  1838                 while (currNative)
  1840                 while (currNative)
  1839                     {
  1841                     {
  1840                     // check for addresses converted from v6 to v4
  1842                     // check for addresses converted from v6 to v4