Ignore:
Timestamp:
Jun 8, 2016 2:49:56 AM (8 years ago)
Author:
nanang
Message:

Close #1926: Support IPv6 address resolution without DNS resolver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_resolve.c

    r5311 r5337  
    196196    struct query *query; 
    197197    pjsip_transport_type_e type = target->type; 
     198    int af = pj_AF_UNSPEC(); 
    198199 
    199200    /* If an external implementation has been provided use it instead */ 
     
    205206    /* Is it IP address or hostname? And if it's an IP, which version? */ 
    206207    ip_addr_ver = get_ip_addr_ver(&target->addr.host); 
     208 
     209    /* Initialize address family type */ 
     210    if ((ip_addr_ver == 6) || (type & PJSIP_TRANSPORT_IPV6)) 
     211        af = pj_AF_INET6(); 
     212    else if (ip_addr_ver == 4) 
     213        af = pj_AF_INET(); 
    207214 
    208215    /* Set the transport type if not explicitly specified.  
     
    242249            } 
    243250        } 
    244  
    245         /* Add IPv6 flag for IPv6 address */ 
    246         if (ip_addr_ver == 6) 
    247             type = (pjsip_transport_type_e)((int)type + PJSIP_TRANSPORT_IPV6); 
    248251    } 
    249252 
     
    272275            pj_addrinfo ai; 
    273276            unsigned count; 
    274             int af; 
    275277 
    276278            PJ_LOG(5,(THIS_FILE, 
     
    281283                      target->addr.port, 
    282284                      pjsip_transport_get_type_name(target->type))); 
    283  
    284             if (type & PJSIP_TRANSPORT_IPV6) { 
    285                 af = pj_AF_INET6(); 
    286             } else { 
    287                 af = pj_AF_INET(); 
    288             } 
    289285 
    290286            /* Resolve */ 
     
    300296            } 
    301297 
    302             svr_addr.entry[0].addr.addr.sa_family = (pj_uint16_t)af; 
    303             pj_memcpy(&svr_addr.entry[0].addr, &ai.ai_addr, 
    304                       sizeof(pj_sockaddr)); 
     298            pj_sockaddr_cp(&svr_addr.entry[0].addr, &ai.ai_addr); 
     299            if (af == pj_AF_UNSPEC()) 
     300                af = ai.ai_addr.addr.sa_family; 
    305301        } 
     302 
     303        /* After address resolution, update IPv6 bitflag in transport type. */ 
     304        if (af == pj_AF_INET6()) 
     305            type |= PJSIP_TRANSPORT_IPV6; 
    306306 
    307307        /* Set the port number */ 
Note: See TracChangeset for help on using the changeset viewer.